﻿using Angle.Krill.Utils;
using AntdUI;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Angle.Krill
{
    public partial class UCImage : UserControl
    {
        private Image icon = null;
        private string title = string.Empty;

        public string IconTitle
        {
            get
            {
                return this.title;
            }
        }
        public UCImage(Image icon, string title)
        {
            InitializeComponent();
            this.SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer, true);
            this.icon = icon;
            this.title = title;
        }

        protected override void OnLoad(EventArgs e)
        {
            this.pBoxIcon.Image = icon;
            this.lblIconName.Text = title;

            base.OnLoad(e);
        }

        private void p_MouseEnter(object sender, EventArgs e)
        {
            this.p.BackColor = Color.FromArgb(28, 151, 234);
            this.lblIconName.ForeColor = Color.White;
        }

        private void p_MouseLeave(object sender, EventArgs e)
        {
            this.p.BackColor = Color.Transparent;
            this.lblIconName.ForeColor = Color.Black;
        }

        private void pBoxIcon_MouseEnter(object sender, EventArgs e)
        {
            this.p.BackColor = Color.FromArgb(28, 151, 234);
            this.lblIconName.ForeColor = Color.White;
        }

        private void lblIconName_MouseEnter(object sender, EventArgs e)
        {
            this.p.BackColor = Color.FromArgb(28, 151, 234);
            this.lblIconName.ForeColor = Color.White;

            Tooltip.open(this.lblIconName, "点击复制", TAlign.Top);
        }

        private void lblIconName_Click(object sender, EventArgs e)
        {
            Clipboard.SetText(this.title);

            this.ParentForm?.Info($"已复制 {title}");
        }
    }
}
